import request from '@/utils/request'

// 查询写作列表
export function listWriter(query) {
  return request({
    url: '/writer/writer/list',
    method: 'get',
    params: query
  })
}

// 查询写作详细
export function getWriter(id) {
  return request({
    url: '/writer/writer/' + id,
    method: 'get'
  })
}

// 新增写作
export function addWriter(data) {
  return request({
    url: '/writer/writer',
    method: 'post',
    data: data
  })
}

// 修改写作
export function updateWriter(data) {
  return request({
    url: '/writer/writer',
    method: 'put',
    data: data
  })
}

// 删除写作
export function delWriter(id) {
  return request({
    url: '/writer/writer/' + id,
    method: 'delete'
  })
}
//获取作家作品
export function getUserNovel(userId) {
  return request({
    url: '/writer/writer/user',
    method: 'get',
    params: { userId }
  })
}
// 查看作品详情
export function getNovelDetail(title) {
  return request({
    url: '/writer/writer/novel/',
    method: 'get',
    params: { title }
  })
}
// 查看章节详情
export function getChapterDetail(title) {
  return request({
    url: '/writer/writer/chapter',
    method: 'get',
    params: { title }
  })
}
//根据小说标题进行修改小说信息
export function updateNovel(data) {
  return request({
    url: '/writer/writer/updateNovel',
    method: 'put',
    data: data
  })
}
// 上传小说封面
export function uploadCover(data) {
  return request({
    url: '/writer/writer/uploadCover',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: data
  })
}
//新增小说章节
export function InsertNovel(data) {
  return request({
    url: '/writer/writer/InsertNovel',
    method: 'post',
    data: data
  })
}
// 根据小说title和章节号查询小说内容
export function getChapterContent(data) {
  return request({
    url: '/writer/writer/getChapterContent',
    method: 'get',
    params: data
  })
}
// 修改小说章节
export function updateChapter(data) {
  return request({
    url: '/writer/writer/updateChapterContent',
    method: 'put',
    data: data
  })
}
// 新增小说
export function addNovel(data) {
  return request({
    url: '/writer/writer/addNovel',
    method: 'post',
    data: data
  })
}
// 查看作者积分
export function calculatePoints(userId) {
  return request({
    url: 'points/points/calculatePoints',
    method: 'post',
    params: { userId }
  })
}